Grokking Microservices Design Patterns
Rate this course
Ask Author
Contribute
Back to course home

0% completed

Vote For New Content
Introduction
Who Should Take This Course?
The Course at a Glance
Strangler Fig Pattern
Introduction
The Problem: Legacy Systems
The Strangler Pattern: A Solution
The Architecture of the Strangler Pattern
Strangler Pattern: A Detailed Example
Key Insights and Implications
API Gateway Pattern
Introduction to the API Gateway Pattern
Advantages of API Gateway Pattern
API Gateway Pattern: An Example
Performance Implications
System Design Example
Backends for Frontends (BFF) Pattern
Introduction to BFF
The Problem: Traditional Backend Models
The Architecture of the BFF Pattern
BFF Pattern: An Example
Performance Implications
System Design Examples
Service Discovery Pattern
What is Service Discovery Pattern?
The Problem: Service Coordination in Distributed Systems
Service Discovery Pattern: A Solution
The Architecture of the Service Discovery Pattern
The Inner Workings of the Service Discovery Pattern
Service Discovery Pattern: An Example
Performance Implications and Special Considerations
System Design Examples
Security Considerations
Circuit Breaker Pattern
Introduction
The Problem: The Struggles of Distributed Systems and Service Failures
The Circuit Breaker Pattern: An Effective Shield Against Cascading Failures
Circuit Breaker Pattern: An Example
Performance Implications and Special Considerations
System Design Examples
Summary
Bulkhead Pattern
Introduction
The Problem: Failure Propagation in Distributed Systems
The Bulkhead Pattern: A Solution
The Architecture
The Inner Workings
Bulkhead Pattern: A Example
Performance Implications and Special Considerations
System Design Examples
Conclusion
Retry Pattern
Introduction
The Retry Pattern: A Solution to Unreliable External Resources
The Architecture of the Retry Pattern
Retry Pattern: An Example
Performance Implications
Use Cases and System Design Examples
Conclusion
Sidecar Pattern
Introduction to the Sidecar Pattern
The Problem: Monolithic Application Management
A Solution to the Monolithic Mayhem
The Architecture of the Sidecar Pattern
Sidecar Pattern: Bringing Theory to Practice with an Example
Performance Implications
System Design Examples: Bringing the Sidecar Pattern to Life
Saga Pattern
Introduction to Saga Pattern
The Problem: Traditional Transaction Models
The Saga Pattern: A Solution
The Architecture of the Saga Pattern
The Inner Workings of the Saga Pattern
Saga Pattern: A Example
Performance Implications
System Design Examples
Conclusion
Event-Driven Architecture Pattern
Introduction
The Problem: Managing Complex Interactions in Distributed Systems
Event-Driven Architecture: A Promising Solution
The Architecture of the Event-Driven Architecture Pattern
The Inner Workings of the Event-Driven Architecture Pattern
Event-Driven Architecture Pattern: An Example
Performance Implications and Special Considerations
Use Cases and System Design Examples
Conclusion
CQRS (Command Query Responsibility Segregation)
Introduction
The Problem: Traditional CRUD Operations
CQRS Pattern: A Solution
The Architecture of the CQRS Pattern
The Inner Workings of the CQRS Pattern
CQRS Pattern: An Example
Issues, Special Considerations, and Performance Implications
System Design Examples
Introduction
The Problem: Configuration Management in a Microservices Architecture
The Solution: Configuration Externalization Pattern
Unveiling the Architecture: How Does Configuration Externalization Work?
Delving into Code: An Example
Considerations and Implications
Use Cases and Real-world Examples
Conclusion
Embrace the Future of Software Architecture
CQRS Pattern: A Solution

Command Query Responsibility Segregation (CQRS) is a design pattern in software architecture that helps solve the kind of problem we just discussed. To understand it better, let's break down the term:

  • Command: This refers to an instruction to do something, like creating, updating, or deleting data (i.e., CUD operations). In our banking example, a command would be processing a deposit or a withdrawal.
  • Query: This is a request to retrieve data without changing it. Checking your account balance in the banking app is a query.
  • Responsibility Segregation: This means dividing responsibilities. In CQRS, it's about separating the responsibilities of handling commands (writes) and queries (reads).

Now, how does CQRS work in simple terms?

  • Separation of Concerns: CQRS divides the system into two parts:
    • The Command Side: This part handles all the write operations. It's responsible for updating data, like processing transactions in our banking app.
    • The Query Side: This part deals with all the read operations. It's optimized for fetching data quickly, like showing your current account balance.

Here is how CQRS looks like with a single Read/Write model with single database.

Separating comamnds (writes) and queries (reads)
Separating comamnds (writes) and queries (reads)
  • State Change: The separation of concerns also distinguishes between methods that change the state and those that don't. This implies that each method of an object falls into one of these categories, but not both:

    • Query: Returns a result. Doesn't change the system’s state or cause any side effects that change the state.
    • Command (also known as modifiers or mutators): Changes the state of a system. Doesn't return a value, only an indication of success or failure.
  • Why is this Useful?

    • Optimization: By separating reads and writes, you can optimize each operation independently. The command side can focus on security and accuracy, while the query side can be optimized for speed.
    • Simplicity: It simplifies the design. Each side (command and query) can be developed and maintained separately, reducing complexity.
    • Scalability: As your application grows, you can scale the read and write operations independently, based on their specific demands.

In essence, CQRS acknowledges that the needs for reading and writing data are different and allows you to treat them separately. This leads to more efficient, maintainable, and scalable systems.

The Problem: Traditional CRUD Operations
The Architecture of the CQRS Pattern
Mark as Completed

On this page